package restful;

public class Plural {

	private static String exception(String name) {
		if (name.endsWith("ys")) {
			name = name.replaceAll("ys$", "ies");
		}
		if (name.equalsIgnoreCase("person")) {
			name = "people";
		}
		return name;
	}

	private static boolean isException(String name) {
		if(name.equals("boys")) return true;
		if(name.equals("person")) return true;
		return false;
	}

	private static boolean isPlural(String name) {
		if(name.equalsIgnoreCase("people")) return true;
		if(name.endsWith("s")) return true;
		return false;
	}

	public static final String plural(String name) {
		if(isPlural(name)) return name;
		if(isException(name)) return exception(name);
		return regular(name);
	}

	private static String regular(String name) {
		name = name.concat("s");
		return name;
	}
}
